﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace System.Web.Mvc
{
    public static class ActiveLinkHelper
    {
        public static string ActiveActionLILink(this HtmlHelper htmlHelper, string linkText, 
            string controlerName, string actionName)
        {
            string _class = String.Empty;
            if (htmlHelper.ViewContext.RouteData.Values["controller"].ToString() == controlerName)
                _class = "active";
            string result = String.Format("<li class=\"{0}\"><a href=\"/{1}/{2}\">{3}</a></li>", 
                _class, controlerName, actionName, linkText);
            return result;
        }
    }
}